<template>
	<view class="auth">
		<button type="default" open-type="getUserInfo" @getuserinfo="onGetUserInfo(userinfo)">授权</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				hasLogin:true,
				userinfo:null
				
			}
		},
		onLoad() {
			this.userAuthrized();
		},
		methods: {
			getUserInfo(e){
				
				
			},
			//判断是否授权
			userAuthrized(){
				let that=this;
				uni.getSetting({
					success:data=>{
						//已经授权获取用户信息
						if(data.authSetting['scope.userInfo']){
							uni.getUserInfo({
								success:data=> {
									that.hasUserInfo = true,
									console.log(data)
									that.userinfo=data.userInfo;
								}
							})
						}
						else{
							that.hasLogin=false;
						}
					},
					fail: (error) => {
						console.log(error)
					}
				})
			},
			onGetUserInfo(userInfo){
				let that =this;
				if(userInfo){
					
				}
			}
			
		}
	}
</script>

<style>
	.auth{
		display: flex;
		justify-content: center;
		align-items: center;
		height: 100vh;
		
	}

</style>
